function isJwtExpired(jwt) {
    const jwtParts = jwt.split('.');
    if (jwtParts.length !== 3) {
        throw new Error('Invalid JWT format');
    }

    const payloadBase64 = jwtParts[1];
    const payloadJson = atob(payloadBase64);
    const payload = JSON.parse(payloadJson);

    if (!payload.hasOwnProperty('exp')) {
        throw new Error('JWT does not have an expiration time');
    }

    const currentTime = Math.floor(Date.now() / 1000);
    return currentTime > payload.exp;
}

